{# A file browser over the object store: the buckets, then one level of a bucket at a time. Folders are the common prefixes a "/" delimiter returns; S3 has no real folders. Writable buckets (every one but the app's own) take uploads into the open folder, and delete one file from its row menu or the checked ones at once. #} {% from "components/macros/layout.html" import card, menu_item %} {% from "components/macros/form.html" import action %} {% from "components/macros/table.html" import data_table %} {% macro entry(value) -%} {%- set glyphs = { "bucket": "M4 7h16l-1.5 12.5a1 1 0 0 1-1 .9h-11a1 1 0 0 1-1-.9L4 7z M3 7h18 M9 11h6", "folder": "M3 6.5A1.5 1.5 0 0 1 4.5 5H9l2 2h8.5A1.5 1.5 0 0 1 21 8.5v9a1.5 1.5 0 0 1-1.5 1.5h-15A1.5 1.5 0 0 1 3 17.5v-11z", "file": "M6 3h8l4 4v14H6z M14 3v4h4", } -%} {%- if value.url %}{{ value.label }} {%- else %}{{ value.label }}{% endif -%} {%- endmacro %} {# Ticks or clears every file on this level; shows a dash when only some are ticked. No ``name``, so it is never counted as a selected file. #} {% macro pick_all() -%} {%- endmacro %} {% macro pick(value) -%} {%- if value.key %}{% endif -%} {%- endmacro %} {# The row's options, out of the way until the row is hovered or focused. #} {% macro file_actions(row) -%} {%- if row.download %}
…
{%- endif -%} {%- endmacro %}
{% if browse.writable and not browse.error %}
selected {{ action("Delete selected", hx_dialog(browse.bulk_delete_url, 'hx-include="[name=\'key\']:checked"'), "danger") }}
{% endif %}
{% if browse.error %} {% else %} {% call card(None, id="storage-browse") %} {{ data_table( ([{"key": "pick", "label": "", "render": pick, "header": pick_all}] if browse.writable else []) + [ {"key": "name", "label": "Name", "render": entry}, {"key": "size", "label": "Size", "align": "right"}, {"key": "modified", "label": "Modified"}, ], browse.rows, actions=file_actions, empty=("Nothing here" if browse.crumbs else "No buckets these credentials can see")) }} {% if browse.truncated %}

Showing the first 1,000 entries at this level.

{% endif %} {% endcall %} {% endif %}